package edu.towson.cosc716.tests;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.Queue;
import org.junit.Before;
import org.junit.Test;
import edu.towson.cosc716.models.Menu;
import edu.towson.cosc716.models.MenuItem;
import edu.towson.cosc716.models.Orders;
import junit.framework.TestCase;

import edu.towson.cosc716.models.Order;
import edu.towson.cosc716.models.Table;

// TODO: Auto-generated Javadoc
/**
 * The Class GetOrdersByTableTest.
 */
public class GetOrdersByTableTest extends ParentTest {

		/** The orders. */
		Orders orders = new Orders();
		
		/* (non-Javadoc)
		 * @see edu.towson.cosc716.tests.ParentTest#setUp()
		 */
		public void setUp() {
			orders.add(new Order(0,9,1.00));
			orders.add(new Order(1,8,2.00));
			orders.add(new Order(2,7,3.00));
			orders.add(new Order(3,6,4.00));
			orders.add(new Order(4,5,5.00));
			orders.add(new Order(0,4,6.00));
			orders.add(new Order(6,3,7.00));
			orders.add(new Order(3,2,8.00));
			orders.add(new Order(0,1,9.00));
			orders.add(new Order(3,0,10.00));
		}

		 /* Test to check that hasNext method is functiong properly.
		 */
		/**
 		 * Test get orders by table has next.
 		 */
 		public void testGetOrdersByTableHasNext() {
			
			//No items meet criteria, price passed in 0.00
			Iterator table5 = orders.getOrdersByTable(5);
			int counter = 0;
			while (table5.hasNext()) {
				table5.next();
				counter++;
			}
			assertEquals(0, counter);
			
			counter = 0;
			//Three items meets criteria (table 3)
			Iterator table3 = orders.getOrdersByTable(3);
			while (table3.hasNext()) {
				table3.next();
				counter++;
			}
			assertEquals(3, counter);
		}
		
		/* 
		 * Test to check that ordersByTable iterator only returns orders from table 3.
		 */
		/**
		 * Test get orders by table test.
		 */
		public void testGetOrdersByTableTest() {
			Iterator testGOBTIter = orders.getOrdersByTable(3);
			boolean allOrdersFromTableThree = true;
			while (testGOBTIter.hasNext()) {
				Order order = (Order) testGOBTIter.next();
				if (order.getTableId()!=3) {
					allOrdersFromTableThree = false;
				}
			}
			assertTrue(allOrdersFromTableThree);
		}
		
	}
